package com.yanqu.road.server.cmd.activity.ppl;

import com.yanqu.road.pb.activity.PplProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_ACTIVITY_PPL_AUTO_USE_GOODS, desc = "领奖期自动使用道具")
public class AutoUseGoodsCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        // 改需求了，不自动使用了，先注释掉
        /*
        if (!PplMgr.isActivityInRewardTime()) {
            ret = GameErrorCode.E_ACTIVITY_PPL_NO_IN_REWARD_TIME;
            return;
        }
        PplModule pplModule = player.getModule(PplModule.class);
        if (!SystemOpenMgr.systemOpen(player, eSystemId.Ppl.getValue())) {
            ret = GameErrorCode.E_ACTIVITY_PPL_SYSTEM_NO_UNLOCK;
            return;
        }
        pplModule.autoUseGoods();
         */
    }

    @Override
    public void sendData(GamePlayer player) {
        PplProto.AutoUseGoodsRespMsg.Builder builder = PplProto.AutoUseGoodsRespMsg.newBuilder();
        builder.setRet(ret);
        player.sendPacket(ClientProtocol.U_ACTIVITY_PPL_AUTO_USE_GOODS, builder);
    }
}
